class WhackController extends UDKBot;

var Pawn playerPawn;
var float activateTime;

DefaultProperties
{
  
}

auto state DoYaThing
{
	event Tick(float delta)
	{
		LookAtPlayer();
		if(!WhackPawn(Pawn).activated)
			activateTime = WorldInfo.TimeSeconds;

		if(WhackPawn(Pawn).activated && activateTime+1 > WorldInfo.TimeSeconds)
			Pawn.StartFire(0);
		else
			Pawn.StopFire(0);
	}
	Begin:
		`log('start');
}

function LookAtPlayer()
{
	if(playerPawn == none)
		FindNearestEnemy();
	Pawn.SetRotation(Rotator(playerPawn.Location - Pawn.Location));
}

function FindNearestEnemy()
{
	local WhackCarAi C;

	foreach WorldInfo.AllControllers(class'WhackCarAi', C)
	{	
		if (C.bIsPlayer && !C.IsDead())
		{
			playerPawn = C.Pawn;
		}
	}
}